package com.nian.common.lock.zookeeper.config;

import org.apache.curator.framework.CuratorFramework;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.integration.zookeeper.config.CuratorFrameworkFactoryBean;
import org.springframework.integration.zookeeper.lock.ZookeeperLockRegistry;

/**
 * 用途：
 * 开发：zhangmj
 * 日期：2020/4/13 0013 20:40
 */
@Configuration
public class ZookeeperLockRegistryConfig {

    @Value("${zookeeper.host-port}")
    private String hostPort;


    @Bean
    CuratorFrameworkFactoryBean curatorFramework() {
        return new CuratorFrameworkFactoryBean(hostPort);
    }

    @Bean
    ZookeeperLockRegistry zookeeperLockRegistry(CuratorFramework client) {
        return new ZookeeperLockRegistry(client);
    }
}
